package day6;

import java.text.DecimalFormat;
import java.util.Scanner;

public class Circle {
    public double r;

    public double getArea(double r){
        double area=Math.PI*r*r;
        return area;
    }
    public double getPerimeter(double r){
        double perimeter=2*Math.PI*r;
        return perimeter;
    }
    public void test(){
        double area=this.getArea(r);
        double perimeter=this.getPerimeter(r);
        DecimalFormat df=new DecimalFormat("#.##");
        String s=df.format(area);
        String p=df.format(perimeter);
        System.out.println("圆的面积为："+s);
        System.out.println("圆的周长为："+p);
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.print("请输入圆的半径：");
        double db=sc.nextDouble();
        Circle cc=new Circle();
        cc.r=db;
        cc.test();
    }
}
